package com.qingmeng.apicommon.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

/**
 * 用户
 *
 * @TableName user
 */
@TableName(value = "user")
@Data
public class User implements Serializable {
    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户昵称
     */
    private String userName;

    /**
     * 账号
     */
    private String userAccount;

    /**
     * 用户头像
     */
    private String userAvatar;

    /**
     * 性别
     */
    private Integer gender;

    /**
     * 用户角色: user, admin
     */
    private String userRole;

    /**
     * 密码
     */
    private String userPassword;

    /**
     * accessKey
     */
    private String accessKey;

    /**
     * secretKey
     */
    private String secretKey;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 是否删除
     */
    @TableLogic
    private Integer isDelete;

    /**
     * 是否登录
     */
    private Integer isLogin;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public User(Long id, User user) {
        this.id = id;
        this.userName = user.getUserName();
        this.userAccount = user.getUserAccount();
        this.userAvatar = user.getUserAvatar();
        this.gender = user.getGender();
        this.userRole = user.getUserRole();
        this.userPassword = user.getUserPassword();
        this.accessKey = user.getAccessKey();
        this.secretKey = user.getSecretKey();
        this.createTime = user.getCreateTime();
        this.updateTime = user.getUpdateTime();
        this.isDelete = user.getIsDelete();
    }

    public User() {

    }
}